﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace Servicios.Notificacion
{
    public class Notificacion:INotificacion
    {
        public void SendMail(string mailBody, string mailTo)
        {
            try
            {
                MailMessage message = new MailMessage();
                message.From = new MailAddress("sebamateo@gmail.com");

                message.To.Add(new MailAddress(mailTo));

                message.Subject = "Nuevo comentario de las Olimpiadas Londres 2012";
                message.Body = mailBody;

                // Create a new Smpt Client using Google's servers
                var mailclient = new SmtpClient();
                mailclient.Host = "smtp.gmail.com";
                mailclient.Port = 587;

                // This is the critical part, you must enable SSL
                mailclient.EnableSsl = true;


                // Specify your authentication details
                mailclient.Credentials = new System.Net.NetworkCredential("sebamateo@gmail.com", "37908051");
                mailclient.Send(message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}
